// 模拟获取 用户数据 订单数据 商品数据
function getUser() {
  setTimeout(() => {
    let data = '用户数据';
    // ?调用next方法,并将数据传入
    iterator.next(data);
  }, 1000);
}

function getOrder() {
  setTimeout(() => {
    let data = '订单数据';
    iterator.next(data);
  }, 1000);
}

function getGoods() {
  setTimeout(() => {
    let data = '商品数据';
    iterator.next(data);
  }, 1000);
}

function* gen() {
  let users = yield getUser();
  console.log(users);
  let orders = yield getOrder();
  console.log(orders);
  let goods = yield getGoods();
  console.log(goods);
}

let iterator = gen();
iterator.next();